package com.cet.designapplication.ordermanagement.command.receiver;

import com.cet.designapplication.pojo.Order;
import org.springframework.stereotype.Component;

/**
 * @author NSOC
 */

@Component
public class OrderCommandReceiver {

    public void action(Order order) {
        switch (order.getOrderState()) {
            case ORDER_WAIT_PAY:
                System.out.println("create order: order = " + order);
                System.out.println("persist to db!");
                return;
            case ORDER_WAIT_SEND:
                System.out.println("pay for order: order = " + order);
                System.out.println("persist to db!");
                System.out.println("inform dept of finance by queue!");
                return;
            case ORDER_WAIT_RECEIVE:
                System.out.println("send cargo: order = " + order);
                System.out.println("persist to db!");
                return;
            case ORDER_FINISHED:
                System.out.println("received order: order = " + order);
                System.out.println("persist to db!");
                return;
            default:
                throw new UnsupportedOperationException("unknown order state!");
        }
    }
}
